/*
 * @file VNC_ILI9341.cpp
 * @date 12.05.2015
 * @author Markus Sattler
 *
 * Copyright (c) 2015 Markus Sattler. All rights reserved.
 * This file is part of the VNC client for Arduino.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2 of the License
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, a copy can be downloaded from
 * http://www.gnu.org/licenses/gpl.html, or obtained by writing to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 *
 *
 */

#include "VNC_config.h"

#ifdef VNC_ST7796S

#include "VNC.h"

#include <TFT_eSPI.h>
#include "VNC_ST7796S.h"

ST7796SVNC::ST7796SVNC() :TFT_eSPI(){
}

bool ST7796SVNC::hasCopyRect(void)
{
    if(1)return 0;
}

uint32_t ST7796SVNC::getHeight(void) {
    return TFT_eSPI::_height;
}

uint32_t ST7796SVNC::getWidth(void) {
    return TFT_eSPI::_width;
}

void ST7796SVNC::draw_area(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint8_t *data) {
    TFT_eSPI::pushImage(x, y, w, h, (uint16_t*)data);
}


void ST7796SVNC::draw_rect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint16_t color) {
    TFT_eSPI::fillRect(x, y, w, h, ((((color) & 0xff) << 8) | (((color) >> 8))));
}

void ST7796SVNC::copy_rect(uint32_t src_x, uint32_t src_y, uint32_t dest_x, uint32_t dest_y, uint32_t w, uint32_t h) {

}

void ST7796SVNC::area_update_start(uint32_t x, uint32_t y, uint32_t w, uint32_t h) {
#ifndef ESP32
    Adafruit_ILI9341::area_update_start(x, y, w, h);
#else
    area_x = x;
    area_y = y;
    area_w = w;
    area_h = h;
#endif

    //TFT_eSPI::setAddrWindow(x, y, w, h);
}

void ST7796SVNC::area_update_data(char *data, uint32_t pixel){
#ifndef ESP32
    Adafruit_ILI9341::area_update_data((uint8_t *)data, pixel);
#else
    TFT_eSPI::pushImage(area_x, area_y,area_w, area_h, (uint16_t*)data);
#endif

    //TFT_eSPI::pushPixels((uint8_t *)data, pixel);
}

void ST7796SVNC::area_update_end(void){
#ifndef ESP32
    Adafruit_ILI9341::area_update_end();
#endif
}

#endif
